package wzc.design_pattern.creation.prototype.shallow_copy;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author 王振川
 * @Date 2025/7/19
 */

public class ShallowCopyDemo {
    public static void main(String[] args) throws CloneNotSupportedException {
        List<String> hobbies = new ArrayList<>();
        hobbies.add("足球");

        Person p1 = new Person("张三", hobbies);
        Person p2 = (Person) p1.clone();

        p2.hobbies.add("篮球");

        System.out.println("原对象爱好：" + p1.hobbies);
        System.out.println("克隆对象爱好：" + p2.hobbies);
    }
}
